package com.hqyj.css.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hqyj.css.pojo.HqyjClass;
import com.hqyj.css.service.ClassService;


@Controller
public class ClassController {
	@Autowired
	ClassService cs;
	@RequestMapping("listClass.cs")
	public String listClass(ModelMap map) {
		List<HqyjClass> list = cs.selectClass();
		map.put("hcs", list);
		return "listClass";
	}
	@RequestMapping("delClass.cs")
	public String delClass(Integer classCode) {
		cs.deleteClass(classCode);
		return "redirect:listClass.cs";
	}
	@RequestMapping("toAddClass.cs")
	public String toAddClass() {
		return "addClass";
	}
	
	@RequestMapping("addClass.cs")
	public String addClass(HqyjClass hc) {
		cs.insertClass(hc);
		return "redirect:listClass.cs";
	}
	
	@RequestMapping("toUpdateClass.cs")
	public String toUpdateClass() {
		return "updateClass";
	}
	
	@RequestMapping("updateClass.cs")
	public String updateClass(HqyjClass hc) {
		
		System.out.println("==============" + hc.getClassCode());
		cs.updateClass(hc);
		return "redirect:listClass.cs";
	}

}
